// $Id: filehandlerrandom.cpp 46 2004-09-29 11:43:36Z jonas $
#include "filehandlerrandom.h"

FileHandlerRandom::~FileHandlerRandom()
{
}

/**
 * Simply return a random file to the node, not caring about who it is...
 *
 * @param requestor Ignored
 * @returns A pointer to a random File object (or null if there are no files!)
 */
File *FileHandlerRandom::getFile(Node */*requestor*/)
{
	// Return null if there are no files in the network
	if (m_files.empty()) {
		return 0;
	}

	return m_files[rand()%m_files.size()];
}

/**
 * Create a file, insert it into the global file list and return it.
 *
 * @param requestor Ignored
 * @returns A pointer to the newly created File object
 */
File *FileHandlerRandom::createFile(Node */*requestor*/)
{
	File *newFile = new File(rand(), rand()%100000000+1);
	m_files.push_back(newFile);
	return newFile;
}
